﻿<!DOCTYPE html>
<html lang="en">
<head profile="http://a9.com/-/spec/opensearch/1.1/">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="./site.css" rel="stylesheet">
<title>compress/lzw</title>
</head>
<body>
<div class="container">
    <h2 id="pkg-overview">package lzw</h2>
    <p><code>import "compress/lzw"</code>
    <p align="left">lzw包实现了Lempel-Ziv-Welch数据压缩格式，这是一种T. A. Welch在&ldquo;A Technique for High-Performance Data Compression&rdquo;一文（Computer, 17(6) (June 1984), pp 8-19）提出的一种压缩格式。</p>
    <p align="left">本包实现了用于GIF、TIFF、PDF文件的lzw压缩格式，这是一种最长达到12位的变长码，头两个非字面码为clear和EOF码。</p>
    <h3 id="pkg-index" class="section-header">Index <a class="permalink" href="#pkg-index">&para;</a></h3>
    <ul class="list-unstyled">
        <li><a href="#Order">type Order</a></li>
        <li><a href="#NewReader">func NewReader(r io.Reader, order Order, litWidth int) io.ReadCloser</a></li>
        <li><a href="#NewWriter">func NewWriter(w io.Writer, order Order, litWidth int) io.WriteCloser</a></li>
    </ul>
    <h3 id="Order">type <a title="View Source" href="http://code.google.com/p/go/source/browse/src/pkg/compress/lzw/reader.go?name=release#25">Order</a> <a class="permalink" href="#Order">&para;</a></h3>
    <pre>type Order <a href="https://godoc.org/builtin#int">int</a></pre>
    <p>Order指定一个lzw数据流的位顺序。</p>
    <pre>const (
    <span class="com">// LSB表示最小权重位在前，用在GIF文件格式</span>
    <span id="LSB">LSB</span> <a href="#Order">Order</a> = <a href="https://godoc.org/builtin#iota">iota</a>
    <span class="com">// MSB表示最大权重位在前，用在TIFF和PDF文件格式</span>
    <span id="MSB">MSB</span>
)</pre>
    <h3 id="NewReader">func <a title="View Source" href="http://code.google.com/p/go/source/browse/src/pkg/compress/lzw/reader.go?name=release#225">NewReader</a> <a class="permalink" href="#NewReader">&para;</a></h3>
    <pre class="funcdecl">func NewReader(r <a href="https://godoc.org/io">io</a>.<a href="https://godoc.org/io#Reader">Reader</a>, order <a href="#Order">Order</a>, litWidth <a href="https://godoc.org/builtin#int">int</a>) <a href="https://godoc.org/io">io</a>.<a href="https://godoc.org/io#ReadCloser">ReadCloser</a></pre>
    <p>创建一个io.ReadCloser，它从r读取并解压数据。调用者有责任在结束读取后调用返回值的Close方法；litWidth指定字面码的位数，必须在[2,8]范围内，一般为8。</p>
    <h3 id="NewWriter">func <a title="View Source" href="http://code.google.com/p/go/source/browse/src/pkg/compress/lzw/writer.go?name=release#234">NewWriter</a> <a class="permalink" href="#NewWriter">&para;</a></h3>
    <pre class="funcdecl">func NewWriter(w <a href="https://godoc.org/io">io</a>.<a href="https://godoc.org/io#Writer">Writer</a>, order <a href="#Order">Order</a>, litWidth <a href="https://godoc.org/builtin#int">int</a>) <a href="https://godoc.org/io">io</a>.<a href="https://godoc.org/io#WriteCloser">WriteCloser</a></pre>
    <p>创建一个io.WriteCloser，它将数据压缩后写入w。调用者有责任在结束写入后调用返回值的Close方法；litWidth指定字面码的位数，必须在[2,8]范围内，一般为8。</p>
</div>
</body>
</html>
